package com.skytech.tax.customsdatawarehouse.singlewindow.customsagententrusted.resource;

import com.skytech.tax.customsdatawarehouse.singlewindow.customsagententrusted.domain.service.EntrustedAgreementService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Lianhong
 * @since 2022/6/15
 */
@RestController
@RequestMapping("/single-window/customs-agent-entrusted/entrusted-agreement")
public class EntrustedAgreementResource {

    @Resource
    private EntrustedAgreementService entrustedAgreementService;

    /**
     * 保存税费单信息
     *
     * @param entrustedAgreement 委托协议
     */
    @PostMapping
    public void saveEntrustedAgreement(@RequestBody String entrustedAgreement) {
        entrustedAgreementService.saveEntrustedAgreement(entrustedAgreement);
    }

    /**
     * 查询委托协议文件名
     *
     * @param seqNo 委托协议编号
     * @return 阿里云存储文件名
     */
    @GetMapping("{seqNo}/file")
    public String entrustedAgreementFile(@PathVariable String seqNo) {
        return entrustedAgreementService.entrustedAgreementFile(seqNo);
    }

    /**
     * 保存委托协议文件名
     *
     * @param seqNo   委托协议编号
     * @param storedFile 存储文件名称
     */
    @PostMapping("{seqNo}/file")
    public void saveEntrustedAgreementFile(@PathVariable String seqNo, @RequestBody String storedFile) {
        entrustedAgreementService.saveCustomsDeclarationFile(seqNo, storedFile);
    }

    /**
     * 委托协议文件是否已存储
     *
     * @param seqNo 委托协议编号
     */
    @GetMapping("{seqNo}/file/stored")
    public boolean entrustedAgreementFileStored(@PathVariable String seqNo) {
        return entrustedAgreementService.entrustedAgreementFileStored(seqNo);
    }
}
